package com.unit3;

// Happy Days！
// Author:bamboo
// Time：2021/11/11 20:38
public class Test {
    public static void main(String[] args) {
        SingleLinkedList linkedList= new SingleLinkedList();
        linkedList.addByOrder(new StudentNode(1,"张三"));
        linkedList.addByOrder(new StudentNode(3,"王五"));
        linkedList.addByOrder(new StudentNode(2,"李四"));
        System.out.println("修改前：");
        linkedList.list();
        linkedList.update(new StudentNode(3,"Tom"));
        System.out.println("修改后：");
        linkedList.delete(2);
        linkedList.list();
        // 求单链表的有效的节点个数
        int len = linkedList.getLength(linkedList.getHead());
        System.out.println(len);

        StudentNode node = linkedList.findLastByIndex(linkedList.getHead(), 1);
        System.out.println("倒数第1个节点："+node);
    }
}
